# 定义函数
def fcount(year, month, day):
    sum = 0
    lst = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
        lst[1] = 29

    for i in range(month - 1):
        sum = sum + lst[i]
    return sum + day


year = int(input())
month = int(input())
day = int(input())

print(fcount(year, month, day))
